package com.zingrow.common.utils;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class PatternUtil {

	/**
	 * 判断字符串是否只为数字及英文
	 * @return 包含其他返回ture
	 */
	public static boolean isNotContain(String str) {

		Pattern p = Pattern.compile("^[a-z0-9A-Z]+$");
		Matcher m = p.matcher(str);
		if (m.find()) {
			return false;
		}
		return true;
	}
	/*
	 * 判断url格式
	 * 
	 * */
	public static boolean  isUrl(String str){
		boolean flag = false;
		try {  
	        Pattern regex = Pattern.compile("(https?|ftp|file)://[-A-Za-z0-9+&@#/%?=~_|!:,.;]+[-A-Za-z0-9+&@#/%=~_|]");
	        Matcher matcher = regex.matcher(str);
	        flag = matcher.matches();
	    } catch (Exception e) {
	        e.printStackTrace();
	        flag = false;

	    }
		
		return flag;
	}
	
	/**
	 * 判断字符串是否只为数字且为11位手机号码
	 * @return 包含其他返回ture
	 */
	public static boolean isNumberPhone(String str) {

		
		
	    boolean flag = false;
	    try {
	        Pattern regex = Pattern.compile("^1[345789]\\d{9}$");
	        Matcher matcher = regex.matcher(str);
	        flag = matcher.matches();
	    } catch (Exception e) {
	        e.printStackTrace();
	        flag = false;

	    }
	    return flag;
	}
	/**
	 * 判断字符串是否只为中文或英文
	 * @return 包含其他返回ture
	 */
	public static boolean isChinese(String str) {

		Pattern p = Pattern.compile("^[\u4e00-\u9fa5a-zA-Z]+$");
		Matcher m = p.matcher(str);
		if (m.find()) {
			return false;
		}
		return true;
	}
	/**
	 * 判断字符串是否为邮箱
	 * @return 包含其他返回ture
	 */
	public static boolean isMailbox(String str) {

	    boolean flag = false;
	    try {
	        String check = "^([a-z0-9A-Z]+[-|_|\\.]?)+[a-z0-9A-Z]@([a-z0-9A-Z]+(-[a-z0-9A-Z]+)?\\.)+[a-zA-Z]{2,}$";
	        Pattern regex = Pattern.compile(check);
	        Matcher matcher = regex.matcher(str);
	        flag = matcher.matches();
	    } catch (Exception e) {
	        flag = false;
	    }
	    return flag;
	}
	
	public static void main(String[] args) {
        System.out.println(isNotContain("））））"));
    }

}
